package com.taobaolite.history;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.util.List;

@RestController
@RequestMapping("/api/v1/history")
public class HistoryController {
    private final HistoryService historyService;

    @Autowired
    public HistoryController(HistoryService historyService) {
        this.historyService = historyService;
    }

    @GetMapping
    public List<HistoryBody> getHistory(@RequestParam("userId") Long userId) {
        return historyService.getHistory(userId);
    }

    @DeleteMapping
    public void deleteHistory(
            @RequestParam("userId") Long userId,
            @RequestParam("time") Timestamp time
    ) {
        historyService.deleteHistory(userId, time);
    }
}
